#include "gtest/gtest.h"
#include <iostream>
#include "WriteBuffer.h"


using namespace frame::imp;

TEST(WriteBufferTest, use){
    WriteBuffer wb;
    std::string str("hello1");
    wb.pushBack(std::move(str));
    ASSERT_EQ(0, str.size());
    ASSERT_EQ(1, wb.size());
    ASSERT_EQ(std::string("hello1"), wb.front());
    ASSERT_EQ(std::string("hello1"), wb.back());

    wb.pushBack("hello3"); //copy
    ASSERT_EQ(2, wb.size());
    ASSERT_EQ(std::string("hello3"), wb.back());

    wb.pushBack("hello7", strlen("hello7")-2);
    ASSERT_EQ(3, wb.size());
    ASSERT_EQ(std::string("hell"), wb.back());

    wb.popBack();
    ASSERT_EQ(2, wb.size());
    ASSERT_EQ(std::string("hello3"), wb.back());

    std::cout << wb << std::endl;
    wb.clear();
    ASSERT_EQ(0, wb.size());
}
